package com.thinkfit.jy.activity;

import com.common.lib.manager.DataManager;
import com.common.lib.utils.BaseUtils;
import com.thinkfit.jy.R;

import java.util.Calendar;

public class MainXMActivity extends MainADActivity {

    @Override
    protected int getLayoutId() {
        return R.layout.activity_main_xm;
    }

    public void resetDate() {
        Calendar now = Calendar.getInstance();
        if (now.get(Calendar.AM_PM) == Calendar.AM) {
            setText(R.id.tvCurrentTime, BaseUtils.StaticParams.getNewText(now.get(Calendar.HOUR_OF_DAY))
                    + ":" + BaseUtils.StaticParams.getNewText(now.get(Calendar.MINUTE)) + " " + getString(R.string.app_am));
        } else {
            setText(R.id.tvCurrentTime, BaseUtils.StaticParams.getNewText(now.get(Calendar.HOUR_OF_DAY) - 12)
                    + ":" + BaseUtils.StaticParams.getNewText(now.get(Calendar.MINUTE)) + " " + getString(R.string.app_pm));
        }
        int year = now.get(Calendar.YEAR);
        int month = now.get(Calendar.MONTH) + 1;
        int day = now.get(Calendar.DAY_OF_MONTH);
        int weekDay = now.get(Calendar.DAY_OF_WEEK);
        setText(R.id.tvDate, BaseUtils.StaticParams.getNewText(year) + "/" + BaseUtils.StaticParams.getNewText(month) + "/" + BaseUtils.StaticParams.getNewText(day) + "  " +
                getString(getResources().getIdentifier("app_weekday_" + weekDay, "string", getPackageName())));
    }

    public void onDestroy() {
        super.onDestroy();
        DataManager.Companion.getInstance().setObject(null);
    }
}